import React, { Component } from 'react'
import { connect } from 'dva';

import { UmiComponentProps, BaseComponentProps } from '@/common/type'
import Imgviewer from '@/components/ImgViewer';

import Details from './components/details'

interface PageProps {
  details: any;
}

interface State {

}

type Props = PageProps & UmiComponentProps & BaseComponentProps;

@connect(({ owner }) => ({
  details: owner.details || {}
}))
class Info extends Component<Props, State> {

  readonly state:State = {
    data: {},
  }

  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({ type: 'owner/queryInfo' })
  }

  render() {
    let { details } = this.props;
    let ans = {
      ...details,
      image: <Imgviewer  url={details.image} hasText="查看图片" missText="暂无图片"/>,
      chemical: +details.chemical ? '否' : '是',
      point: `${details.x || ''}, ${details.y || ''}`
    }
    return (
      <>
        <Details data={ans}/>
      </>
    );
  }
}

export default Info;
